package com.liuwei.spring.cloud.framework.constants;

import java.util.concurrent.TimeUnit;

/**
 * @author : RedisConfig
 * @version V1.0
 * @date: 2023/11/25 10:08 PM
 * @Description: TODO
 */
public class CaffeineCache {

    /** CacheManager 名称 */
    public static final String CACHE_MANAGER = "caffeine_cache";

    public static final String CAFFEINE_TTL_NO_EXPIRE ="CAFFEINE_TTL_NO_EXPIRE";
    public static final String CAFFEINE_TTL_5_SECONDS ="CAFFEINE_TTL_5_SECONDS";
    public static final String CAFFEINE_TTL_10_SECONDS ="CAFFEINE_TTL_10_SECONDS";
    public static final String CAFFEINE_TTL_30_SECONDS ="CAFFEINE_TTL_30_SECONDS";
    public static final String CAFFEINE_TTL_60_SECONDS ="CAFFEINE_TTL_60_SECONDS";
    public static final String CAFFEINE_TTL_5_MINUTES ="CAFFEINE_TTL_5_MINUTES";
    public static final String CAFFEINE_TTL_10_MINUTES ="CAFFEINE_TTL_10_MINUTES";
    public static final String CAFFEINE_TTL_30_MINUTES ="CAFFEINE_TTL_30_MINUTES";
    public static final String CAFFEINE_TTL_60_MINUTES ="CAFFEINE_TTL_60_MINUTES";
    public static final String CAFFEINE_TTL_2_HOURS ="CAFFEINE_TTL_2_HOURS";
    public static final String CAFFEINE_TTL_6_HOURS ="CAFFEINE_TTL_6_HOURS";
    public static final String CAFFEINE_TTL_12_HOURS ="CAFFEINE_TTL_12_HOURS";
    public static final String CAFFEINE_TTL_24_HOURS ="CAFFEINE_TTL_24_HOURS";
    public static final String CAFFEINE_TTL_2_DAYS ="CAFFEINE_TTL_3_DAYS";
    public static final String CAFFEINE_TTL_3_DAYS ="CAFFEINE_TTL_3_DAYS";
    public static final String CAFFEINE_TTL_5_DAYS ="CAFFEINE_TTL_5_DAYS";
    public static final String CAFFEINE_TTL_7_DAYS ="CAFFEINE_TTL_7_DAYS";
    public static final String CAFFEINE_TTL_15_DAYS ="CAFFEINE_TTL_15_DAYS";
    public static final String CAFFEINE_TTL_30_DAYS ="CAFFEINE_TTL_30_DAYS";
    public static final String CAFFEINE_TTL_60_DAYS ="CAFFEINE_TTL_60_DAYS";
    public static final String CAFFEINE_TTL_90_DAYS ="CAFFEINE_TTL_90_DAYS";
    public static final String CAFFEINE_TTL_180_DAYS ="CAFFEINE_TTL_180_DAYS";
    public static final String CAFFEINE_TTL_360_DAYS ="CAFFEINE_TTL_360_DAYS";
    /**
     * 通过声明枚举 CacheProperty 方便统一声明对应的 Cache
     * 常量的 value 数量和值需要和枚举的名称保持一致
     */
    public enum CacheProperty{
        CAFFEINE_TTL_NO_EXPIRE(-1, null),
        CAFFEINE_TTL_5_SECONDS(5, TimeUnit.SECONDS),
        CAFFEINE_TTL_10_SECONDS(10, TimeUnit.SECONDS),
        CAFFEINE_TTL_30_SECONDS(30, TimeUnit.SECONDS),
        CAFFEINE_TTL_60_SECONDS(60,TimeUnit.SECONDS),
        CAFFEINE_TTL_5_MINUTES(5,TimeUnit.MINUTES),
        CAFFEINE_TTL_10_MINUTES(10,TimeUnit.MINUTES),
        CAFFEINE_TTL_30_MINUTES(30,TimeUnit.MINUTES),
        CAFFEINE_TTL_60_MINUTES(60,TimeUnit.MINUTES),
        CAFFEINE_TTL_2_HOURS(2,TimeUnit.HOURS),
        CAFFEINE_TTL_6_HOURS(6,TimeUnit.HOURS),
        CAFFEINE_TTL_12_HOURS(12,TimeUnit.HOURS),
        CAFFEINE_TTL_24_HOURS(24,TimeUnit.HOURS),
        CAFFEINE_TTL_2_DAYS(2,TimeUnit.DAYS),
        CAFFEINE_TTL_3_DAYS(3,TimeUnit.DAYS),
        CAFFEINE_TTL_5_DAYS(5,TimeUnit.DAYS),
        CAFFEINE_TTL_7_DAYS(7,TimeUnit.DAYS),
        CAFFEINE_TTL_15_DAYS(15,TimeUnit.DAYS),
        CAFFEINE_TTL_30_DAYS(30,TimeUnit.DAYS),

        CAFFEINE_TTL_60_DAYS(60,TimeUnit.DAYS),

        CAFFEINE_TTL_90_DAYS(90,TimeUnit.DAYS),

        CAFFEINE_TTL_180_DAYS(180,TimeUnit.DAYS),

        CAFFEINE_TTL_360_DAYS(360,TimeUnit.DAYS),
        ;

        private long ttl;
        private TimeUnit unit;

        CacheProperty(long ttl, TimeUnit unit){
            this.ttl = ttl;
            this.unit = unit;
        }

        public long getTtl() {
            return ttl;
        }

        public TimeUnit getUnit() {
            return unit;
        }
    }

}
